<?php

namespace app\admin\controller;

use think\Controller;

class ResourceController extends Controller
{
    protected function initialize()
    {
        parent::initialize();
        $this->server = model('server.resource');
    }

    public function uploadImgOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('UPLOAD_SUCCESS')];
        $responseData['data'] = $this->server->uploadImg();

        return $responseData;
    }

    public function uploadFileOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('UPLOAD_FILE_SUCCESS')];
        $responseData['data'] = $this->server->uploadFile();

        return $responseData;
    }

    public function setResourceStatusOp()
    {
        $postData = validateRequestParam('resource', 'setResourceStatus');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SET_SUCCESS')];
        $responseData['data'] = $this->server->setResourceStatus($postData);

        return $responseData;
    }

    public function delExpFileOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('DEL_SUCCESS')];
        $responseData['data'] = $this->server->delExpFile();

        return $responseData;
    }

    public function getResourceGaroupListOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getResourceGaroupList();

        return $responseData;
    }

    public function saveResourceGaroupAddOp()
    {
        $postData = validateRequestParam('resource', 'saveResourceGaroupAdd');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveResourceGaroupAdd($postData);

        return $responseData;
    }

    public function getResourceGaroupRowOp()
    {
        $postData = validateRequestParam('roles', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getResourceGaroupRow($postData);

        return $responseData;
    }

    public function saveResourceGaroupEditOp()
    {
        $postData = validateRequestParam('roles', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveResourceGaroupEdit($postData);

        return $responseData;
    }

    public function saveResourceGaroupDelOp()
    {
        $postData = validateRequestParam('roles', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('DEL_SUCCESS')];
        $responseData['data'] = $this->server->saveResourceGaroupDel($postData);

        return $responseData;
    }

    public function getResourceGaroupAllOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getResourceGaroupAll();

        return $responseData;
    }
}
